package com.backend.models;

import io.ebean.ExpressionList;
import io.ebean.Finder;
import io.ebean.Model;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "product_collect")
@Data
public class ProductCollect extends Model {
    @Id
    public Integer id;
    public Integer userId;
    @ManyToOne
    @JoinColumn(name = "product_id")
    public Product product;
    public boolean isCollected = false;
    public Date lastModifyTime;

    public static Finder<Integer, ProductCollect> find = new Finder<>(ProductCollect.class);

    public static ExpressionList<ProductCollect> search() {
        return ProductCollect.find.query().where();
    }
}
